﻿using UnityEngine;
using System.Collections;
namespace GameUnit
{
    public static class EffectManager
    {
        public static Hashtable EffectsTable;

        public static void Load(string effectFilePath)
        {
            EffectsTable = (Hashtable)SGLisp.Helper.EvalValueFromFile(effectFilePath);
            
        }

        public static Effect CreateEffect(string effectName,Unit srcUnit = null)
        {
            Hashtable effectConfig = (Hashtable)EffectsTable[effectName];
            string effectType = (string)effectConfig[":type"];
            Effect newEffect = (Effect)System.Activator.CreateInstance(System.Type.GetType("GameUnit."+ effectType));
            newEffect.Init(effectConfig,srcUnit);
            return newEffect;
        }
    }
}